import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "@/views/HomeView.vue";

Vue.use(VueRouter);

const routes = [
	// {
	//   path: '/',
	//   name: 'home',
	//   component: () => import('@/components/shs_upload_class.vue'),
	// meta:{title:'测试页面'}
	// },
	// 首页
	{
		path: "/",
		name: "home",
		component: HomeView,
		meta: {
			title: "社会数"
		},
	},
	// 关于我
	{
		path: "/about",
		name: "about",
		meta: {
			title: "社会数"
		},
		component: () => import("@/views/AboutView.vue"),
	},
	// 发布留言
	{
		path: "/publishArticle",
		name: "publishArticle",
		meta: {
			title: "社会数"
		},
		component: () => import("@/views/publishArticleView.vue"),
	},
	// 登录
	{
		path: "/login",
		name: "login",
		meta: {
			title: "社会数"
		},
		component: () => import("@/views/loginView.vue"),
	},
	// 后台
	{
		path: "/backStage",
		name: "backStage",
		meta: {
			title: "社会数-"
		},
		component: () => import("@/views/backStageView.vue"),
		children: [{
				path: "/backStage/main",
				name: "backStage.main",
				meta: {
					title: "社会数-"
				},
				component: () => import("@/views/backStage/main.vue"),
			},
			// {
			//   path: "/backStage/article",
			//   name: "backStage.article",
			//   component: () => import("@/views/backStage/article.vue"),
			// },
			{
				path: "/backStage/classlist",
				name: "backStage.classlist",
				meta: {
					title: "社会数---分类管理"
				},
				component: () => import("@/views/backStage/classList.vue"),
			},
			{
				path: "/backStage/tagList",
				name: "backStage.tagList",
				meta: {
					title: "社会数---标签管理"
				},
				component: () => import("@/views/backStage/tagList.vue"),
			},

			{
				path: "/backStage/blogroll",
				name: "backStage.blogroll--友情链接",
				meta: {
					title: "社会数---友情链接"
				},
				component: () => import("@/views/backStage/blogroll.vue"),
			},
			{
				path: "/backStage/article_item",
				name: "backStage.article_item--文章管理",
				meta: {
					title: "社会数---文章管理"
				},
				component: () => import("@/views/backStage/article_item.vue"),
			},
			// {
			//   path: "/backStage/user_control",
			//   name: "backStage.user_control--用户管理详情",
			//   component: () => import("@/views/backStage/user_control.vue"),
			// },
			{
				path: "/backStage/user_information",
				name: "user_information",
				meta: {
					title: "社会数---用户信息中心"
				},
				component: () => import("@/views/backStage/user_information.vue"),
			},
			

		],
	},
	{
		path: "*",
		name: "404",
		meta: {
			title: "未找到！！！"
		},
		component: () => import("@/views/undefinedView.vue"),
	},
	{
		path: "/managelogin",
		name: "managelogin",
		meta: {
			title: "社会数--管理员登录"
		},
		component: () => import("@/views/manageLoginView.vue"),
	},
	{
		path: "/blogrollView",
		name: "blogrollView",
		meta: {
			title: "社会数--友情链接"
		},
		component: () => import("@/views/blogrollView.vue"),
	},
	{
		path: "/articleHome",
		name: "articleHome",
		meta: {
			title: "社会数--文章"
		},
		component: () => import("@/components/articleHome.vue"),
	}

];

const router = new VueRouter({
	routes,
	mode: "history"
});
// 重复点击路由，导致提示避免到当前位置的冗余导航（路由冗余）解决方式
//     pust方法
const routerRePush = VueRouter.prototype.push
VueRouter.prototype.push = function(location) {
	return routerRePush.call(this, location).catch(error => error)
}
//     replace 方法
const routerReplace = VueRouter.prototype.replace
VueRouter.prototype.replace = function(location) {
	return routerReplace.call(this, location).catch(error => error)
}
router.beforeEach((to, from, next) => {
	if (to.meta.title) {
		document.title = to.meta.title;
	}
	next();
});
export default router;